<template>
     <div class="app-container"   >
      <el-row     :gutter="20" style="padding: 0px 19px" class="parent"  v-if="this.$route.query.queryParam=='self'">
  <el-col :span="3.5" v-for="(alarm) in alarmsList"   :key=" alarm.id" class="child" style="margin:0 0 18px 0;text-align:center;" >
    <!-- <div class="tip">{{(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize)<10?'0'+(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize):(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize)}}</div> -->
    <el-button  style="font-size:18px;  width:100%;height:100px;padding:3px;margin:0px; background-color:#32c8c9 ;color: #fff;text-wrap:wrap;" @click="jump(alarm.id,alarm.deviceIds)" >

        {{alarm.name}}

    </el-button>
  </el-col>
      </el-row>

      <el-row :gutter="20" style="padding:0 19px" class="parent" v-else-if="this.$route.query.queryParam=='all'">
  <el-col :span="3.5"  v-for="(dep,index) in deptList" class="child"   :key=" dep.deptId" style="margin:0 0 18px 0;text-align:center;" >
    <!-- <el-card body-style="text-align:center;line-height:100px;"  > -->
  <div>

    <div class="tip">{{(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize)<10?'0'+(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize):(index + 1 + (queryParams.pageNum- 1) * queryParams.pageSize)}}</div>
   <el-button style="font-size:18px; width:100%;height:100px;padding:3px;margin:0px; background-color:#32c8c9 ;color: #fff;text-wrap:wrap;" @click="jump(dep.deptId)"> {{dep.deptName}}    </el-button>

  </div>
  </el-col>
      </el-row>
      <pagination
        v-show="total>0"
    :page-sizes="[20, 30, 50]"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
     </div>
</template>
<script>
import { listAlarms } from "@/api/system/alarms";
import { listDepts } from "@/api/system/depts";
export default {
  name: "monitor",
  created() {
    if( this.$route.query.queryParam=='self' ){
        this.getAlarmList();
    }
    else if( this.$route.query.queryParam=='all' ){
      this.getDeptList();
    }
  },
  methods:{
    indexMethod(index) {

return index + 1 + (this.queryParams.pageNum- 1) * this.queryParams.pageSize

  },
    getList(){
      if(this.$route.query.queryParam=='self'){//自定义
         this.getAlarmList();
      }else{//区域 全部
        this.getDeptList();

      }
    },
    getDeptList() {
      this.loading = true;
      this.queryParams.orderByColumn = "deptCode";
      this.queryParams.isAsc ="ascending";
        listDepts(this.queryParams).then((response) => {
        console.log(response);
        this.deptList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
     getAlarmList(){
      this.loading = true;
        listAlarms(this.queryParams).then(response => {
        this.alarmsList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    jump(id,ids){
        this.$router.push({ path:"/system/device-data/monitor", query:{"id":id,"ids":ids,"source":this.$route.query.queryParam}})
    },
  },
  data(){
    return{
        deptList: [],
        loading :false,
        total: 0,
        alarmsList:[],
         // 查询参数
         queryParams: {
            pageNum: 1,
            pageSize: 20,
         }
  }
}
}
</script>
<style scoped>


.tip {
  margin: 2px;
    padding: 1px;
    color: rgb(52 88 124 / 75%);

    border-radius: 20% 0% 40% 0%;
    background-color: rgb(122 132 216 / 19%);
    position: absolute;float:left;margin: 2px;
}

.el-row {
    margin-bottom: 20px;

  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

.parent {
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
}
.child{
  flex-basis: 20%;
}
</style>
